
import Vue from "vue";
import $ from "jquery";

import {Hos} from "../hos/hos.js";
import {wx} from "../hos/wx.js";

import {Activity} from "./activity.js";
import {os, StateBarStyle} from "../hos/os.js";

class Checker extends Activity {

    onCreate() {
        super.onCreate();

        $(this.find("log")).append("入口地址:" + location.href + "<br>");
        $(this.find("log")).append("Hos version:" + Hos.versionNumber() + "<br>");
        $(this.find("log")).append("WiFi ip:" + Hos.ip() + "<br>");
        $(this.find("log")).append("调试地址:" + Hos.ip() + ":8297/cmd/<br>");

        if (!Hos.isHos()) {
            $(this.find("log")).append("你运行在浏览器中" + "<br>");

        } else {
            $(this.find("log")).append("你运行在Hos中" + "<br>");
        }

        Hos.echo({"msg": "你好吗"}).then(response=>{
            $(this.find("log")).append("回环测试返回:" + response.msg + "<br>");
        }, error=>{
            $(this.find("log")).append("回环测试错误:" + error.errMsg + "<br>");
        });

        $(this.find("log")).append("是否安装了微信:" + wx.isWXAppInstalled() + "<br>");
        $(this.find("log")).append("是否支持该版本微信:" + wx.isWXAppSupport() + "<br>");
        $(this.find("log")).append("安全区" + JSON.stringify(os.layoutSafeArea()) + "<br>");

        $("stateBar").css("height", "300px");

    }
    onResume() {
        super.onResume();
        os.setStateBarStyle(StateBarStyle.LIGHT);
    }
}

export {Checker};
